---------------------------------------------------------------------------------------------------- -- Physics hit checker ---------------------------------------------------------------------------------------------------- -- Разработчик: Andrey Fidrya (Zmey) af@svitonline.com ---------------------------------------------------------------------------------------------------- class "ph_on_hit" function ph_on_hit:__init(obj, storage) self.object = obj self.st = storage end function ph_on_hit:reset_scheme() end function ph_on_hit:update(delta) end function ph_on_hit:hit_callback(obj, amount, local_direction, who, bone_index) local who_name if who then who_name = who:name() else who_name = "nil" end --printf("_bp: ph_on_hit:hit_callback: obj='%s', amount=%d, who='%s', bone='%s'", obj:name(), amount, who_name, tostring(bone_index)) if db.storage[self.object:id()].active_scheme then if xr_logic.try_switch_to_another_section(obj, self.st, db.actor) then return end end end function ph_on_hit:deactivate() --printf("PH_ON_HIT: deactivate") end --------------------------------------------------------------------------------------------------------------------- function setup_generic_scheme(npc,ini,scheme,section,stype,temp) local hit_section = ini:r_string_ex(section,"on_hit") if not (hit_section) then return end local st = xr_logic.assign_storage_and_bind(npc,ini,scheme,section,temp) st.logic = xr_logic.cfg_get_switch_conditions(ini, section, npc) xr_logic.subscribe_action_for_events(npc, st, st.action) end function add_to_binder(npc,ini,scheme,section,storage,temp) storage.action = ph_on_hit(npc,storage) end function disable_generic_scheme(npc,scheme,stype) local st = db.storage[npc:id()][scheme] if st then xr_logic.unsubscribe_action_from_events(npc, st, st.action) end end